<?php
    ob_start();
    session_start();

    $url = basename($_SERVER['PHP_SELF']);
    if ($url == 'index.php' or $url == 'register.php' or $url == 'forgot.php' or $url == 'activation.php')    {
        if ($_SESSION['user_email'] != '') {
            header('location:main.php');
        }
    }else if ($url == 'main.php' or $url == 'chest.php' or $url == 'triceps.php' or $url == 'legs.php' or $url == 'abs.php' or $url == 'shoulders.php' or $url == 'biceps.php' or $url == 'back.php' or $url == 'profile.php' or $url == 'search.php' or $url == 'statistik.php')   {       
        if ($_SESSION['user_email'] == '') {
            header('location:index.php');
        }
    }else if ($url == '10-weeks-program.php')   {
        if ($_SESSION['user_email'] == '')  {
            header('location:../index.php');
        }
    }
    
    $db_host = '127.0.0.1';
    $db_username = 'root';
    $db_password = '';
    $db_select_db = 'mylimit';
    $db_user_inf = 'user_inf';
    $db_workouts_name = 'workouts';
    
    $connection = mysql_connect($db_host, $db_username, $db_password) or die ('could not connect with server ' . mysql_error());
    mysql_select_db($db_select_db) or die ('could not reach database ' . mysql_error());
?>